#pragma once

// [日志级别][时间戳][日志信息][错误文件名称][行数]

#include <iostream>
#include <string>
#include <ctime>

enum{
    Info = 1,
    Debug,
    Warning,
    Error,
    Fatal
};

// #level: 将数字转化为字符串形式
#define LOG(level, message) Log(#level, message, __FILE__, __LINE__)

void Log(std::string level, std::string message, std::string file_name, int line)
{
    time_t t = time(nullptr);
    struct tm *ctime = localtime(&t);
    printf("[%s][%d-%d-%d %d:%d:%d][%s][%s][%d]\n", level.c_str(),
        ctime->tm_year+1900, ctime->tm_mon+1, ctime->tm_mday, ctime->tm_hour,
        ctime->tm_min, ctime->tm_sec, message.c_str(), file_name.c_str(), line);
}